<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>医疗保险查询</title>
    <meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="stylesheet" href="../../plugins/mui/mui.min.css">
    <link rel="stylesheet" href="../../css/my/security/index.css" />
    <script src="../../js/statistics.js"></script>
    <script src="../../js/fontset.js"></script>
    <style>

    </style>
</head>
<body>
<header class="mui-bar mui-bar-nav header">
    <a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
    <h1 class="mui-title">医疗保险查询</h1>
</header>
<div class="mui-content content-info">
	<div class="mui-row guide" id="guide">
		<div class="mui-col-xs-6 guide-item active">
			<a href="javascript:void(0);">缴费信息</a>
		</div>
		<div class="mui-col-xs-6 guide-item">
			<a href="javascript:void(0);">账户信息</a>
		</div>
	</div>
	<div class="group group-top" >
		<div class="group-item active" id="paymentInfo">
			
		</div>
		<div class="group-item" id="accountInfo">
			
		</div>
	</div>
	
</div>	

<script type="text/javascript" src="../../plugins/jquery/jquery-3.1.0.min.js"></script>
<script src="../../plugins/mui/mui.min.js"></script>
<!--<script type="text/javascript" src="../plugins/mui/update.js"></script>-->
<script src="../../js/getApiToken.js"></script>
<script src="../../js/md5.js"></script>
<script src="../../plugins/template/template.js" ></script>
<script src="../../js/life_housekeeper/windowTitleView.js"></script>
<script type="text/html" id="paymentList">
	<ul class="mui-table-view">
		<li class="mui-table-view-cell">
			<p>社会保障号：</p>
			<p>{{user.AKC020}}</p>
		</li>
		<li class="mui-table-view-cell">
			<p>参保人姓名：</p>
			<p>{{user.AAC003}}</p>
		</li>
	</ul>
	{{each list.list as item}}
	<ul class="mui-table-view">
		<li class="mui-table-view-cell">
			<p>缴纳年月：</p>
			<p>{{item.JFNY}}</p>
		</li>
		<li class="mui-table-view-cell">
			<p>缴纳基数：</p>
			<p>{{item.JFJS}}</p>
		</li>
		<li class="mui-table-view-cell">
			<p>个人缴纳：</p>
			<p>{{item.GRJN}}</p>
		</li>
		<li class="mui-table-view-cell">
			<p>单位缴纳：</p>
			<p>{{item.DWJN}}</p>
		</li>
		<li class="mui-table-view-cell">
			<p>缴纳总额：</p>
			<p>{{item.JNZJE}}</p>
		</li>
		<li class="mui-table-view-cell">
			<p>参保单位：</p>
			<p>{{item.CBDW}}</p>
		</li>
	</ul>
	{{/each}}
</script>
<script type="text/html" id="accountList">	
	<ul class="mui-table-view">
        <li class="mui-table-view-cell">
            <p>身份证号：</p>
            <p>{{balance.AAC002}}</p>
        </li>
        <li class="mui-table-view-cell">
            <p>参保人姓名：</p>
            <p>{{balance.AAC003}}</p>
        </li>
        <li class="mui-table-view-cell">
            <p>账户余额：</p>
            <p>{{balance.ZHYE}}</p>
        </li>
    </ul>
	{{each list.list as item}}
    <ul class="mui-table-view">
        <li class="mui-table-view-cell">
            <p>账户变动日期：</p>
            <p>{{item.BDRQ}}</p>
        </li>
        <li class="mui-table-view-cell">
            <p>变动方向：</p>
            <p>{{item.BDFX}}</p>
        </li>
        <li class="mui-table-view-cell">
            <p>变动金额：</p>
            <p>{{item.BDJE}}</p>
        </li>
        <li class="mui-table-view-cell">
            <p>备注信息：</p>
            <p>{{item.AAE013}}</p>
        </li>
    </ul>
    {{/each}}
</script>
<script type="text/javascript">
	mui.init();
	mui.plusReady(function(){
		plus.nativeUI.showWaiting('正在查询，请稍后',{
			modal:false,
			back:'close'
		});
		mui("#guide").on('tap','.guide-item',function(e){
			var index  = $(this).index(); 
			$(this).addClass('active').siblings('.guide-item').removeClass('active');
			$(".group .group-item").eq(index).addClass("active").siblings(".group-item").removeClass('active');
		});
		var userId = plus.storage.getItem('cg_user_id');
		myAjax('/home/Social/medical','post',{
			userId:userId
		},function(e){
			plus.nativeUI.closeWaiting();
			//console.log(JSON.stringify(e));
			if(e.code == '0'){
				var paymentInfo = document.getElementById("paymentInfo"),
				paymentHtml = template('paymentList',e);
				paymentInfo.innerHTML = paymentHtml;
			}else{
				var msg = e.message;
					mui.toast('查询失败，'+msg);
				setTimeout(function(){
					mui.back();
				},1500);
			}
		})
		myAjax('/home/Social/change','post',{userId:userId},function(e){
			//console.log(JSON.stringify(e));
			if(e.code == '0' && e.balance){
				var accountInfo = document.getElementById("accountInfo"),
				accountHtml = template('accountList',e);
				accountInfo.innerHTML = accountHtml;
			}else{
				mui.toast('账户信息查询失败');
				plus.nativeUI.closeWaiting();
			}
		})
		var self = plus.webview.currentWebview();
		var back = function(){
	            self.close();
	        }
		 mui.back = function(){
			plus.nativeUI.closeWaiting();
			back();	
		}
		//showInfo(data,indexInfo)
	})
	
	
	
	
	function showInfo(paymentData,accountData,callback){
		var paymentInfo = document.getElementById("paymentInfo"),
			accountInfo = document.getElementById("accountInfo"),
			accountHtml = template('accountList',accountData),
			paymentHtml = template('paymentList',paymentData);
			paymentInfo.innerHTML = paymentHtml;
			accountInfo.innerHTML = accountHtml;
			callback();
	}
	
	function indexInfo(){
		mui("#guide").on('tap','.guide-item',function(e){
			var index  = $(this).index(); 
			$(this).addClass('active').siblings('.guide-item').removeClass('active');
			$(".group .group-item").eq(index).addClass("active").siblings(".group-item").removeClass('active');
		})
	}
	
	
</script>
</body>
</html>
